<?php session_start();?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="../../../object/coreObject/fix/FixArticleTypeObj.js"></script>
<title></title>
</head>
<body>
<script LANGUAGE="javascript">
var fixArticleTypeObj = new FixArticleTypeObj();
var url = "../../article.php?type=";
function redirectPageComplete(type)
{	
	alert("บันทึกบทความสำเร็จ");
	location = url+type;
}

function redirectPageIncomplete(type)
{
	alert("เกิดข้อผิดพลาดในการเพิ่มข้อมูล");
	location = url+type;
}

function redirectPageIsnull(type)
{
	alert("ข้อมูลบางส่วนยังเป็น่ค่าว่าง กรุณาลงใหม่อีกครั้ง");
	location = url+type;
	
}


<?php
include '../../../dbconfig.php';

$author = addslashes($_POST['article_author']);
$title = addslashes($_POST['article_title']);
$description = htmlentities($_POST['article_description'], ENT_QUOTES, "UTF-8");;
$status = $_POST['article_status'];
$type = addslashes($_POST['article_type']);
$inserted_master_id = $_SESSION['uid'];
$inserted_datetime = date("Y-m-d H:i:s");
$modified_mid = $_SESSION['uid'];
$modified_datetime = date("Y-m-d H:i:s"); //เก็บวันเดือนปีและเวลาด้วย function date

if(isset($type ,$author,$title,$description,$status,$modified_mid,$modified_datetime)){
	$sql = "INSERT INTO article (fix_article_type,reference_st,title,description,fix_status,inserted_master_id,inserted_date_time,modified_master_id,modified_date_time)
	VALUES ($type, '$author', '$title', '$description', '$status',$inserted_master_id,'$inserted_datetime', $modified_mid, '$modified_datetime')";
	if(mysql_query($sql)){
	 	echo "redirectPageComplete($type);";
	}else{	
		echo $sql;
		echo "redirectPageIncomplete($type);";
	}
	
	mysql_close();
	
}
else
{
	echo "redirectPageIncomplete($type);";
}
?>
</script>
</body>
</html>
